home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0574.ZIP / FCLOSE.ASM < prev    next >
Assembly Source File  |  1986-12-07  |  633b  |  46 lines

  1. include compiler.inc
  2.     ttl    FCLOSE, 1.05, 10-16-86, jwk
  3.  
  4. ;close io stream
  5.  
  6.     dseg
  7.     exterr
  8.  
  9.     cseg
  10.     xtfs    <close,$strhand>
  11.  
  12.     procdef    fclose, <<stream, ptr>>
  13.     pushreg
  14.     pushds
  15.     moverr    0
  16.  
  17.     callit    $strhand <<stream,ptr>>
  18.     inc    ax
  19.     jz    ex        ;bad pointer, ERR=0
  20.     dec    ax
  21.  
  22.     callit    close,<<ax,reg>>
  23.     or    ax,ax        ;returned NULL
  24.     jz    ok        ;yes, okay
  25. ;
  26. seteof:
  27.     moverr    ax        ;no, set error code
  28.     mov    ax,-1        ;and return EOF
  29.     jmp    short ex
  30. ;
  31. ok:
  32.     ldptr    si,stream
  33.     xor    ax,ax
  34.     mov    4[si],al    ;ERCD
  35.     mov    3[si],al    ;CRFLG
  36.     mov    2[si],al    ;MODE - not open
  37.     dec    ax
  38.     mov    [si],ax        ;no UGC
  39.     inc    ax
  40. ex:    pret
  41.  
  42.     pend    fclose
  43.  
  44.     finish
  45. 
  46.